package com.example.myapplication.Fragment;

import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.example.myapplication.MainActivity2;
import com.example.myapplication.MainActivity3;
import com.example.myapplication.R;

public class fragment_1 extends Fragment implements View.OnClickListener {
    private MediaPlayer mediaPlayer;
    private Button bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9;

    @Nullable
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_1, container, false);

        bt1 = view.findViewById(R.id.button);
        bt2 = view.findViewById(R.id.button2);
        bt3 = view.findViewById(R.id.button3);
        bt4 = view.findViewById(R.id.button4);
        bt5 = view.findViewById(R.id.button6);
        bt6 = view.findViewById(R.id.button7);
        bt7 = view.findViewById(R.id.button8);
        bt8 = view.findViewById(R.id.button9);
        bt9 = view.findViewById(R.id.button10);

        bt1.setOnClickListener(this);
        bt2.setOnClickListener(this);
        bt3.setOnClickListener(this);
        bt4.setOnClickListener(this);
        bt5.setOnClickListener(this);
        bt6.setOnClickListener(this);
        bt7.setOnClickListener(this);
        bt8.setOnClickListener(this);
        bt9.setOnClickListener(this);

        return view;
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.button) {
            mediaPlayer = MediaPlayer.create(requireContext(), R.raw.hhh);
            mediaPlayer.start();
        } else if (id == R.id.button2) {
            mediaPlayer = MediaPlayer.create(requireContext(), R.raw.sb);
            mediaPlayer.start();
        } else if (id == R.id.button3) {
            mediaPlayer = MediaPlayer.create(requireContext(), R.raw.sun);
            mediaPlayer.start();
        } else if (id == R.id.button4) {
            mediaPlayer = MediaPlayer.create(requireContext(), R.raw.nhndm);
            mediaPlayer.start();
        } else if (id == R.id.button6) {
            mediaPlayer = MediaPlayer.create(requireContext(), R.raw.smy);
            mediaPlayer.start();
        } else if (id == R.id.button7) {
            mediaPlayer = MediaPlayer.create(requireContext(), R.raw.ysln);
            mediaPlayer.start();
        } else if (id == R.id.button8) {
            mediaPlayer = MediaPlayer.create(requireContext(), R.raw.bjl);
            mediaPlayer.start();
        } else if (id == R.id.button9) {
            Intent intent = new Intent(requireContext(), MainActivity2.class);
            startActivity(intent);
        } else if (id == R.id.button10) {
            Intent intent = new Intent(requireContext(), MainActivity3.class);
            startActivity(intent);
        }
    }
}
